<template>
    <el-container style="height: 80vh;width: 1350px;margin-left: 170px;background-color:#9bcda616;">
      <!-- 主体 -->
      <el-container>
        <!-- 侧边栏 -->
        <el-aside width="200px">
          <el-menu router>
            <span style="margin-left:-90px;">
                <el-upload
                  class="avatar-uploader"
                  action="https://jsonplaceholder.typicode.com/posts/"
                  :show-file-list="false"
                  :on-success="handleAvatarSuccess"
                  :before-upload="beforeAvatarUpload"
                >
                  <img v-if="imageUrl" :src="imageUrl" class="avatar">
                  <i v-else class="el-icon-plus avatar-uploader-icon">
                    <el-avatar :icon="UserFilled" />
                </i>
                </el-upload>
          </span>
            <el-menu-item index="/GerenXinxi">
              <i class="el-icon-user"></i>
              <span slot:="title" style="color: dodgerblue;">
                    个人信息     
            </span>
            </el-menu-item>
            <el-menu-item style="color: dodgerblue;" index="/ScoreQuery">
              <i class="el-icon-trophy"></i>
              <span slot:="title">成绩查询</span>
            </el-menu-item>
            <el-menu-item style="color: dodgerblue;" index="/DingdanChaxun">
              <i class="el-icon-bell"></i>
              <span slot:="title">订单查询</span>
            </el-menu-item>
            <el-menu-item style="color: dodgerblue" index="/NotificationCenter">
              <i class="el-icon-bell"></i>
              <span slot:="title">通知中心</span>
            </el-menu-item>
            <el-button style="margin-left: -30px;" type="text" @click="logout" >退出/切换账号</el-button>
          </el-menu>
        </el-aside>
        <!-- 主要内容区域 -->
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </template>
  <script>
  export default {
    data() {
      return {
      };
    },
    methods: {
      logout() {
        // 退出逻辑
        console.log('退出登录');
        this.$router.push('/LoginForm');
      },
      handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!');
      }
      return isJPG &&isLt2M;
    }
  }
    }
  ;
  </script>
  
  <style> 
  .avatar-uploader .el-upload {
  border: 0px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #f3f5f717;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #e8ecf221;
  width: 128px;
  height: 98px;
  line-height: 98px;
  margin-left: -40px;
 
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
  .el-aside {
    background-color: #9bcda616;
    color: #333;
  }
  
  .el-main {
    background-color: #e9f0eb16;
    color: #333;
  }
  </style>
  